<html lang="en">

<head>
    <meta charset="UTF-8">

    <title>js的事件处理</title>
</head>

<body>
    <button>点击改变颜色</button>
    <script>
        const btn = document.querySelector("button");
        function random(number) {
            return Math.floor(Math.random() * (number + 1))

        }
        btn.addEventListener("click", () => {
            const rndCol = `rgb(${random(255)} ${random(255)} ${random(255)})`;
            document.body.style.backgroundColor = rndCol;
        })



    </script>
</body>

</html>